package com.sky.web.app;

import com.sky.constant.StatusConstant;
import com.sky.dto.SetmealPageDTO;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.SetmealVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user/setmeal")
public class AppSetmealController {
    @Autowired
    private SetmealService setmealService;
    @GetMapping("list")
    @Cacheable(key = "#categoryId",value = "setmeal",unless = "#result.data.size()==0")
    public Result findListByCategory4App(Long categoryId){
        SetmealPageDTO pageDTO = SetmealPageDTO.builder()
                .categoryId(categoryId)
                .status(StatusConstant.ENABLE)
                .build();
       List<SetmealVO> list = setmealService.findListByCategory4App(pageDTO);
       return Result.success(list);
    }
}
